home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / lib / perl5 / Glib / BookmarkFile.pod next >
Encoding:
Text File  |  2008-11-04  |  13.1 KB  |  753 lines

  1. =head1 NAME
  2.  
  3. Glib::BookmarkFile -  Parser for bookmark files
  4.  
  5. =for position SYNOPSIS
  6.  
  7. =head1 SYNOPSIS
  8.  
  9.   use Glib;
  10.  
  11.   $date .= $_ while (<DATA>);
  12.  
  13.   $b = Glib::BookmarkFile->new;
  14.   $b->load_from_data($data);
  15.   $uri = 'file:///some/path/to/a/file.txt';
  16.   if ($b->has_item($uri)) {
  17.       $title = $b->get_title($uri);
  18.     $desc  = $b->get_description($uri);
  19.  
  20.     print "Bookmark for `$uri' ($title):\n";
  21.     print "  $desc\n";
  22.   }
  23.   0;
  24.  
  25.   __DATA__
  26.   <?xml version="1.0" encoding="UTF-8"?>
  27.   <xbel version="1.0"
  28.         xmlns:bookmark="http://www.freedesktop.org/standards/desktop-bookmarks"
  29.         xmlns:mime="http://www.freedesktop.org/standards/shared-mime-info">
  30.     <bookmark href="file:///tmp/test-file.txt" added="2006-03-22T18:54:00Z" modified="2006-03-22T18:54:00Z" visited="2006-03-22T18:54:00Z">
  31.       <title>Test File</title>
  32.       <desc>Some test file</desc>
  33.       <info>
  34.         <metadata owner="http://freedesktop.org">
  35.           <mime:mime-type type="text/plain"/>
  36.           <bookmark:applications>
  37.             <bookmark:application name="Gedit" exec="gedit %u" timestamp="1143053640" count="1"/>
  38.           </bookmark:applications>
  39.         </metadata>
  40.       </info>
  41.     </bookmark>
  42.   </xbel>
  43.  
  44. =for position DESCRIPTION
  45.  
  46. =head1 DESCRIPTION
  47.  
  48. B<Glib::BookmarkFile> lets you parse, edit or create files containing lists
  49. of bookmarks to resources pointed to by URIs, with some meta-data bound to
  50. them, following the Desktop Bookmark Specification.  The recent files support
  51. inside GTK+ uses this type of files to store the list of recently used
  52. files.
  53.  
  54. The syntax of bookmark files is described in detail in the Desktop Bookmarks
  55. Specification, here is a quick summary: bookmark files use a subclass of the
  56. XML Bookmark Exchange Language (XBEL) document format, defining meta-data
  57. such as the MIME type of the resource pointed by a bookmark, the list of
  58. applications that have registered the same URI and the visibility of the
  59. bookmark.
  60.  
  61. =cut
  62.  
  63.  
  64.  
  65. =for object Glib::BookmarkFile Parser for bookmark files
  66. =cut
  67.  
  68.  
  69.  
  70.  
  71. =head1 METHODS
  72.  
  73. =head2 bookmarkfile = Glib::BookmarkFile-E<gt>B<new> 
  74.  
  75. =over
  76.  
  77. =back
  78.  
  79. =head2 $bookmark_file-E<gt>B<add_application> ($uri, $name, $exec)
  80.  
  81. =over
  82.  
  83. =over
  84.  
  85. =item * $uri (string) 
  86.  
  87. =item * $name (string or undef) 
  88.  
  89. =item * $exec (string or undef) 
  90.  
  91. =back
  92.  
  93. Adds the application with $name and $exec to the list of
  94. applications that have registered a bookmark for $uri into
  95. $bookmark_file.
  96.  
  97. Every bookmark inside a C<Glib::BookmarkFile> must have at least an
  98. application registered.  Each application must provide a name, a
  99. command line useful for launching the bookmark, the number of times
  100. the bookmark has been registered by the application and the last
  101. time the application registered this bookmark.
  102.  
  103. If $name is undef, the name of the application will be the
  104. same returned by Glib::get_application_name(); if $exec is undef,
  105. the command line will be a composition of the program name as
  106. returned by Glib::get_prgname() and the "%u" modifier, which will
  107. be expanded to the bookmark's URI.
  108.  
  109. This function will automatically take care of updating the
  110. registrations count and timestamping in case an application
  111. with the same $name had already registered a bookmark for
  112. $uri inside the bookmark file.  If no bookmark for $uri is found
  113. one is created.
  114.  
  115. =back
  116.  
  117. =head2 $bookmark_file-E<gt>B<add_group> ($uri, $group)
  118.  
  119. =over
  120.  
  121. =over
  122.  
  123. =item * $uri (string) 
  124.  
  125. =item * $group (string) 
  126.  
  127. =back
  128.  
  129. Adds $group to the list of groups to which the bookmark for $uri
  130. belongs to.  If no bookmark for $uri is found one is created.
  131.  
  132. =back
  133.  
  134. =head2 unix timestamp = $bookmark_file-E<gt>B<get_added> ($uri)
  135.  
  136. =over
  137.  
  138. =over
  139.  
  140. =item * $uri (string) 
  141.  
  142. =back
  143.  
  144. =for apidoc __gerror__
  145. Gets the time the bookmark for $uri was added to $bookmark_file.
  146.  
  147. =back
  148.  
  149. =head2 Glib::BookmarkFile::set_added ($bookmark_file, $uri, $value)
  150.  
  151. =over
  152.  
  153. =over
  154.  
  155. =item * $bookmark_file (Glib::BookmarkFile) 
  156.  
  157. =item * $uri (string) 
  158.  
  159. =item * $value (unix timestamp) 
  160.  
  161. =back
  162.  
  163. Sets the time the bookmark for $uri was added.
  164. If no bookmark for $uri is found one is created.
  165.  
  166. =back
  167.  
  168. =head2 ($exec, $count, $stamp) = $bookmark_file->B<get_app_info> ($uri, $name)
  169.  
  170. =over
  171.  
  172. =over
  173.  
  174. =item * $uri (string) 
  175.  
  176. =item * $name (string) 
  177.  
  178. =back
  179.  
  180. Gets the registration informations of $name for the bookmark for
  181. $uri.  See Glib::BookmarkFile::set_app_info() for more informations about
  182. the returned data.
  183.  
  184. May croak with a L<Glib::Error> in $@ on failure.
  185.  
  186. =back
  187.  
  188. =head2 $bookmark_file-E<gt>B<set_app_info> ($uri, $name, $exec, $count, $stamp)
  189.  
  190. =over
  191.  
  192. =over
  193.  
  194. =item * $uri (string) 
  195.  
  196. =item * $name (string) 
  197.  
  198. =item * $exec (string) 
  199.  
  200. =item * $count (integer) 
  201.  
  202. =item * $stamp (unix timestamp) 
  203.  
  204. =back
  205.  
  206. Sets the meta-data of application $name inside the list of
  207. applications that have registered a bookmark for $uri inside
  208. $bookmark_file.
  209.  
  210. You should rarely use this method; use Glib::BookmarkFile::add_application()
  211. and Glib::BookmarkFile::remove_application() instead.
  212.  
  213. $name can be any UTF-8 encoded string used to identify an application.
  214. $exec can have one of these two modifiers: "%f", which will be expanded
  215. as the local file name retrieved from the bookmark's URI; "%u", which
  216. will be expanded as the bookmark's URI. The expansion is done automatically
  217. when retrieving the stored command line using the
  218. Glib::BookmarkFile::get_app_info() method.
  219. $count is the number of times the application has registered the
  220. bookmark; if it is < 0, the current registration count will be increased
  221. by one, if it is 0, the application with $name will be removed from
  222. the list of registered applications.
  223. $stamp is the Unix time of the last registration, as returned by time(); if
  224. it is -1, the current time will be used.
  225.  
  226. If you try to remove an application by setting its registration count to
  227. zero, and no bookmark for $uri is found, %FALSE is returned and an
  228. exception is fired.
  229.  
  230. May croak with a L<Glib::Error> in $@ on failure.
  231.  
  232. =back
  233.  
  234. =head2 list = $bookmark_file->B<get_applications> ($uri)
  235.  
  236. =over
  237.  
  238. =over
  239.  
  240. =item * $uri (string) 
  241.  
  242. =back
  243.  
  244. Retrieves the names of the applications that have registered the
  245. bookmark for $uri.
  246.  
  247. May croak with a L<Glib::Error> in $@ on failure.
  248.  
  249. =back
  250.  
  251. =head2 $bookmark_file->B<get_description> ($uri)
  252.  
  253. =over
  254.  
  255. =over
  256.  
  257. =item * $uri (string) 
  258.  
  259. =back
  260.  
  261. Gets the description of the bookmark for $uri.
  262.  
  263. May croak with a L<Glib::Error> in $@ on failure.
  264.  
  265. =back
  266.  
  267. =head2 $bookmark_file-E<gt>B<set_description> ($uri, $description)
  268.  
  269. =over
  270.  
  271. =over
  272.  
  273. =item * $uri (string) 
  274.  
  275. =item * $description (string) 
  276.  
  277. =back
  278.  
  279. Sets the description of the bookmark for $uri.  If no bookmark for $uri
  280. is found one is created.
  281.  
  282. =back
  283.  
  284. =head2 list = $bookmark_file-E<gt>B<get_groups> ($uri)
  285.  
  286. =over
  287.  
  288. =over
  289.  
  290. =item * $uri (string) 
  291.  
  292. =back
  293.  
  294. Retrieves the list of group names of the bookmark for $uri.
  295.  
  296. May croak with a L<Glib::Error> in $@ on failure.
  297.  
  298. =back
  299.  
  300. =head2 $bookmark_file-E<gt>B<set_groups> ($uri, ...)
  301.  
  302. =over
  303.  
  304. =over
  305.  
  306. =item * $uri (string) 
  307.  
  308. =item * ... (list) one or more group names
  309.  
  310. =back
  311.  
  312. Sets a list of group names for the item with URI $uri.  Each previously
  313. set group name list is removed.  If no bookmark for $uri is found one
  314. is created.
  315.  
  316. =back
  317.  
  318. =head2 boolean = $bookmark_file-E<gt>B<has_application> ($uri, $name)
  319.  
  320. =over
  321.  
  322. =over
  323.  
  324. =item * $uri (string) 
  325.  
  326. =item * $name (string) 
  327.  
  328. =back
  329.  
  330. Checks whether the bookmark for $uri inside $bookmark_file has
  331. been registered by application $name.
  332.  
  333. May croak with a L<Glib::Error> in $@ on failure.
  334.  
  335. =back
  336.  
  337. =head2 boolean = $bookmark_file-E<gt>B<has_group> ($uri, $group)
  338.  
  339. =over
  340.  
  341. =over
  342.  
  343. =item * $uri (string) 
  344.  
  345. =item * $group (string) 
  346.  
  347. =back
  348.  
  349. Checks whether $group appears in the list of groups to which
  350. the bookmark for $uri belongs to.
  351.  
  352. May croak with a L<Glib::Error> in $@ on failure.
  353.  
  354. =back
  355.  
  356. =head2 boolean = $bookmark_file-E<gt>B<has_item> ($uri)
  357.  
  358. =over
  359.  
  360. =over
  361.  
  362. =item * $uri (string) 
  363.  
  364. =back
  365.  
  366. Looks whether the bookmark file has a bookmark for $uri.
  367.  
  368. =back
  369.  
  370. =head2 ($href, $mime_type) = $bookmark_file->B<get_icon> ($uri)
  371.  
  372. =over
  373.  
  374. =over
  375.  
  376. =item * $uri (string) 
  377.  
  378. =back
  379.  
  380. Gets the icon of the bookmark for $uri.
  381.  
  382. May croak with a L<Glib::Error> in $@ on failure.
  383.  
  384. =back
  385.  
  386. =head2 $bookmark_file-E<gt>B<set_icon> ($uri, $href, $mime_type)
  387.  
  388. =over
  389.  
  390. =over
  391.  
  392. =item * $uri (string) 
  393.  
  394. =item * $href (string or undef) 
  395.  
  396. =item * $mime_type (string or undef) 
  397.  
  398. =back
  399.  
  400. Sets the icon for the bookmark for $uri.  If $href is undef, unsets
  401. the currently set icon.
  402.  
  403. =back
  404.  
  405. =head2 boolean = $bookmark_file-E<gt>B<get_is_private> ($uri)
  406.  
  407. =over
  408.  
  409. =over
  410.  
  411. =item * $uri (string) 
  412.  
  413. =back
  414.  
  415.  
  416.  
  417. May croak with a L<Glib::Error> in $@ on failure.
  418.  
  419. =back
  420.  
  421. =head2 $bookmark_file-E<gt>B<set_is_private> ($uri, $is_private)
  422.  
  423. =over
  424.  
  425. =over
  426.  
  427. =item * $uri (string) 
  428.  
  429. =item * $is_private (boolean) 
  430.  
  431. =back
  432.  
  433.  
  434.  
  435. =back
  436.  
  437. =head2 $bookmark_file-E<gt>B<load_from_data> ($buf)
  438.  
  439. =over
  440.  
  441. =over
  442.  
  443. =item * $buf (scalar) 
  444.  
  445. =back
  446.  
  447. Parses a string containing a bookmark file structure.
  448.  
  449. May croak with a L<Glib::Error> in $@ on failure.
  450.  
  451. =back
  452.  
  453. =head2 ($full_path) = $bookmark_file->B<load_from_data_dirs> ($file)
  454.  
  455. =over
  456.  
  457. =over
  458.  
  459. =item * $file (localized file name) 
  460.  
  461. =back
  462.  
  463.  
  464. Parses a bookmark file, searching for it inside the data directories.
  465. If a file is found, it returns the full path.
  466.  
  467. May croak with a L<Glib::Error> in $@ on failure.
  468.  
  469. =back
  470.  
  471. =head2 $bookmark_file-E<gt>B<load_from_file> ($file)
  472.  
  473. =over
  474.  
  475. =over
  476.  
  477. =item * $file (localized file name) 
  478.  
  479. =back
  480.  
  481. Parses a bookmark file.
  482.  
  483. May croak with a L<Glib::Error> in $@ on failure.
  484.  
  485. =back
  486.  
  487. =head2 string = $bookmark_file-E<gt>B<get_mime_type> ($uri)
  488.  
  489. =over
  490.  
  491. =over
  492.  
  493. =item * $uri (string) 
  494.  
  495. =back
  496.  
  497. Gets the MIME type of the bookmark for $uri.
  498.  
  499. May croak with a L<Glib::Error> in $@ on failure.
  500.  
  501. =back
  502.  
  503. =head2 $bookmark_file-E<gt>B<set_mime_type> ($uri, $mime_type)
  504.  
  505. =over
  506.  
  507. =over
  508.  
  509. =item * $uri (string) 
  510.  
  511. =item * $mime_type (string) 
  512.  
  513. =back
  514.  
  515. Sets the MIME type of the bookmark for $uri.  If no bookmark for $uri
  516. is found one is created.
  517.  
  518. =back
  519.  
  520. =head2 unix timestamp = $bookmark_file-E<gt>B<get_modified> ($uri)
  521.  
  522. =over
  523.  
  524. =over
  525.  
  526. =item * $uri (string) 
  527.  
  528. =back
  529.  
  530. =for apidoc __gerror__
  531. Gets the time the bookmark for $uri was last modified.
  532.  
  533. =back
  534.  
  535. =head2 Glib::BookmarkFile::set_modified ($bookmark_file, $uri, $value)
  536.  
  537. =over
  538.  
  539. =over
  540.  
  541. =item * $bookmark_file (Glib::BookmarkFile) 
  542.  
  543. =item * $uri (string) 
  544.  
  545. =item * $value (unix timestamp) 
  546.  
  547. =back
  548.  
  549. Sets the time the bookmark for $uri was last modified.
  550. If no bookmark for $uri is found one is created.
  551.  
  552. =back
  553.  
  554. =head2 $bookmark_file-E<gt>B<move_item> ($old_uri, $new_uri)
  555.  
  556. =over
  557.  
  558. =over
  559.  
  560. =item * $old_uri (string) 
  561.  
  562. =item * $new_uri (string or undef) 
  563.  
  564. =back
  565.  
  566. Changes the URI of a bookmark item from $old_uri to $new_uri.  Any
  567. existing bookmark for $new_uri will be overwritten.  If $new_uri is
  568. undef, then the bookmark is removed.
  569.  
  570. May croak with a L<Glib::Error> in $@ on failure.
  571.  
  572. =back
  573.  
  574. =head2 $bookmark_file-E<gt>B<remove_application> ($uri, $name)
  575.  
  576. =over
  577.  
  578. =over
  579.  
  580. =item * $uri (string) 
  581.  
  582. =item * $name (string) 
  583.  
  584. =back
  585.  
  586. Removes application registered with $name from the list of applications
  587. that have registered a bookmark for $uri inside $bookmark_file.
  588.  
  589. May croak with a L<Glib::Error> in $@ on failure.
  590.  
  591. =back
  592.  
  593. =head2 $bookmark_file-E<gt>B<remove_group> ($uri, $group)
  594.  
  595. =over
  596.  
  597. =over
  598.  
  599. =item * $uri (string) 
  600.  
  601. =item * $group (string) 
  602.  
  603. =back
  604.  
  605. Removes $group from the list of groups to which the bookmark
  606. for $uri belongs to.
  607.  
  608. May croak with a L<Glib::Error> in $@ on failure.
  609.  
  610. =back
  611.  
  612. =head2 $bookmark_file-E<gt>B<remove_item> ($uri)
  613.  
  614. =over
  615.  
  616. =over
  617.  
  618. =item * $uri (string) 
  619.  
  620. =back
  621.  
  622. Removes the bookmark for $uri from the bookmark file.
  623.  
  624. May croak with a L<Glib::Error> in $@ on failure.
  625.  
  626. =back
  627.  
  628. =head2 integer = $bookmark_file-E<gt>B<get_size> 
  629.  
  630. =over
  631.  
  632. Gets the number of bookmarks inside the bookmark file.
  633.  
  634. =back
  635.  
  636. =head2 $bookmark_file->B<get_title> ($uri, $title)
  637.  
  638. =over
  639.  
  640. =over
  641.  
  642. =item * $uri (string) 
  643.  
  644. =back
  645.  
  646. Gets the title of the bookmark for $uri.
  647.  
  648. May croak with a L<Glib::Error> in $@ on failure.
  649.  
  650. =back
  651.  
  652. =head2 $bookmark_file-E<gt>B<set_title> ($uri, $title)
  653.  
  654. =over
  655.  
  656. =over
  657.  
  658. =item * $uri (string) 
  659.  
  660. =item * $title (string) 
  661.  
  662. =back
  663.  
  664. Sets the title of the bookmark for $uri.  If no bookmark for $uri is found
  665. one is created.
  666.  
  667. =back
  668.  
  669. =head2 string = $bookmark_file-E<gt>B<to_data> 
  670.  
  671. =over
  672.  
  673. Returns the bookmark file as a string.
  674.  
  675. May croak with a L<Glib::Error> in $@ on failure.
  676.  
  677. =back
  678.  
  679. =head2 $bookmark_file-E<gt>B<to_file> ($file)
  680.  
  681. =over
  682.  
  683. =over
  684.  
  685. =item * $file (localized file name) 
  686.  
  687. =back
  688.  
  689. Saves the contents of a bookmark file into a file.  The write operation
  690. is guaranteed to be atomical by writing the contents of the bookmark file
  691. to a temporary file and then moving the file to the target file.
  692.  
  693. May croak with a L<Glib::Error> in $@ on failure.
  694.  
  695. =back
  696.  
  697. =head2 list = $bookmark_file->B<get_uris>
  698.  
  699. =over
  700.  
  701. Returns the URI of all the bookmarks in the bookmark file.
  702.  
  703. =back
  704.  
  705. =head2 unix timestamp = $bookmark_file-E<gt>B<get_visited> ($uri)
  706.  
  707. =over
  708.  
  709. =over
  710.  
  711. =item * $uri (string) 
  712.  
  713. =back
  714.  
  715. =for apidoc __gerror__
  716. Gets the time the bookmark for $uri was last visited.
  717.  
  718. =back
  719.  
  720. =head2 Glib::BookmarkFile::set_visited ($bookmark_file, $uri, $value)
  721.  
  722. =over
  723.  
  724. =over
  725.  
  726. =item * $bookmark_file (Glib::BookmarkFile) 
  727.  
  728. =item * $uri (string) 
  729.  
  730. =item * $value (unix timestamp) 
  731.  
  732. =back
  733.  
  734. Sets the time the bookmark for $uri was last visited.
  735. If no bookmark for $uri is found one is created.
  736.  
  737. =back
  738.  
  739.  
  740. =head1 SEE ALSO
  741.  
  742. L<Glib>
  743.  
  744. =head1 COPYRIGHT
  745.  
  746. Copyright (C) 2003-2008 by the gtk2-perl team.
  747.  
  748. This software is licensed under the LGPL.  See L<Glib> for a full notice.
  749.  
  750.  
  751. =cut
  752.  
  753.